<template>
  <div class="head">
    <div class="top" >
      <img
        src="http://s3.pstatp.com/toutiao/xitu_juejin_web/img/logo.a7995ad.svg"
        alt=""
      />
      <ul>
        <li v-for="(item, key) in data" :key="key">
          <router-link :to="item.path">
            {{ item.title }}
          </router-link>
        </li>
      </ul> 
      <div>
        <h2>
          <input type="text" placeholder="探索掘金" />
          <img
            src="//s3.pstatp.com/toutiao/xitu_juejin_web/img/juejin-search-icon.6f8ba1b.svg"
            alt=""
          />
        </h2>
        <h1>
          <button>写文章</button>
          <span>▼</span>
        </h1>
        <p>
          <button v-if="!localval&&!$store.state.loginState"  @click="isLogin">登陆</button>
          <span v-if="localval|$store.state.loginState"  class="iconfont icon-lingdang"></span>
          <img v-if="localval|$store.state.loginState"  src="./1.jpg" alt="" @click.stop="logout()">
        </p>
      </div>
      <MyCom v-if="$store.state.myComisShow"> </MyCom>
    </div>
  </div>
</template>

<script>
import MyCom from '../myCom/message'
import { createHead } from "../../router/router.config";
export default {
  components:{
        MyCom
  },
  data() {
    return {
      data: createHead(),
      id: 0,
      localval:localStorage.getItem('isLogin'),
      flag:false
    };
  },
  methods: {
    isLogin(){
      this.$store.commit('IsShowTrue')
    },
    //点击头像弹框出现
    logout(){
      this.$store.commit('myComisTrue')
    },
    
  },
  created(){
    // console.log(this.localval)
  },
  match:{
    localval: {
      handler(newval,oldval) {
        console.log(newval,oldval)
      },
      deep:true,
      immediate:true,
    }
  }
};
</script>

<style scoped lang="scss">
.head {
  margin: auto;
  width: 100%;
  height: 60px;
  line-height: 60px;
  border-bottom: 1px solid #f1f1f1;
  background-color: white;
  .top {
    max-width: 960px;
    height: 100%;
    margin: auto;
    position: relative;
    background: no-repeat;
    background-repeat: no-repeat;
    img {
      margin-top: 10px;
      float: left;
      margin-right: 20px;
    }
    ul {
      float: left;
      overflow: hidden;
      li {
        float: left;
        width: 67px;
        height: 60px;

        text-align: center;
        font-size: 16px;
        a {
          color: #71777c;
          &:hover {
            color: #007fff;
          }
        }
        .router-link-active {
          color: #007fff;
        }
      }
    }
    div {
      float: right;
      overflow: hidden;
      height: 100%;
      line-height: 0;
      padding-top: 13px;
      h2 {
        float: left;
        margin-right: 27px;
        input {
          width: 168px;
          height: 33px;
          position: relative;
          border: 1px solid hsla(0, 0%, 59.2%, 0.2);
        }
        img {
          position: absolute;
          top: 8px;
          right: 190px;
        }
      }

      h1 {
        width: 80px;
        height: 32px;
        float: left;
        margin-right: 15px;
        button {
          background-color: #007fff;
          width: 60px;
          height: 100%;
          color: #fff;
          float: left;
        }
        span {
          width: 19px;
          border-left: 1px solid #198bff;
          height: 100%;
          text-align: center;
          line-height: 35px;
          color: #fff;
          background-color: #007fff;
          float: left;
        }
      }
      p {
        float: left;
        button {
          width: 72px;
          height: 32px;
          border: 1px solid #007fff;
          color: #0e82ff;
        }
        span{
          font-size: 28px;
          height: 20px;
          float: left;
          margin: 15px 10px;
          &:hover{
            color: #007fff;
          }
        }
        img{
          width: 30px;
          height: 30px;
          border-radius: 50%;
          margin: 0;
          
        }
      }
    }
  }
}
</style>